#ifndef __LM_WIN_H__
#define __LM_WIN_H__

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "curses.h"
#include "panel.h"
#include "lm_sys.h"
#include "lm_color.h"
#include "../common/lm_error.h"


typedef struct lm_win {
    WINDOW      *body;
    WINDOW      *box;
    PANEL       *panel;
    int32_t     pos_x;
    int32_t     pos_y;
    int32_t     width;
    int32_t     height;
    lm_color_t   color;

}lm_win_t;


typedef struct lm_title_win {
    lm_win_t    window;
    const char* title;

}lm_title_win_t;


typedef struct lm_query_win {
    lm_win_t window;
    const char* title;
    const char* text;
    bool status;

}lm_query_win_t;


#ifdef __cplusplus
extern "C" {
#endif

static inline int lm_win_get_term_width(void)
{
    return COLS;
}

static inline int lm_win_get_term_height(void)
{
    return LINES;
}


WINDOW* lm_win_new(WINDOW *parent, int32_t pos_x, int32_t pos_y, int32_t width, int32_t height);
void lm_win_destory(WINDOW* win);
int lm_win_set_color(WINDOW *win, lm_color_t color);
int lm_win_get_color(lm_win_t *win);
void lm_win_set_text(lm_win_t *win, const char* text);
void lm_win_set_pos_text(lm_win_t *win, int32_t x, int32_t y, const char* text, int color);
void lm_win_set_pos_text_no_refresh(lm_win_t *win, int32_t x, int32_t y, const char* text, int color);
void lm_win_clear_text(lm_win_t *win);


lm_win_t* lm_win_create(lm_win_t *parent, int32_t pos_x, int32_t pos_y, int32_t width, int32_t height, lm_color_t color);
lm_win_t* lm_edge_win_create(lm_win_t *parent, int32_t pos_x, int32_t pos_y, int32_t width, int32_t height, lm_color_t color);
void lm_win_delete(lm_win_t *win);
void lm_win_scrol_up(lm_win_t *win);
void lm_win_scrol_down(lm_win_t *win);
void lm_win_update(lm_win_t* win);
void lm_win_refresh(lm_win_t* win);
int lm_win_get_width(lm_win_t* win);
int lm_win_get_height(lm_win_t* win);


lm_title_win_t* lm_title_win_create(lm_win_t *parent, int32_t pos_x, int32_t pos_y, int32_t width, int32_t height, const char* title, lm_color_t color);
void lm_title_win_delete(lm_title_win_t *win);
void lm_title_win_set_text(lm_title_win_t *win, const char* text);
void lm_title_win_set_pos_text(lm_title_win_t *win, int32_t x, int32_t y, const char* text, int color);
void lm_title_win_scrol_up(lm_title_win_t *win);
void lm_title_win_scrol_down(lm_title_win_t *win);
void lm_title_win_refresh(lm_title_win_t* win);


lm_query_win_t* lm_query_win_create(lm_win_t *parent, int32_t pos_x, int32_t pos_y, int32_t width, int32_t height, const char* title, bool status, lm_color_t color);
void lm_query_win_delete(lm_query_win_t *win);
void lm_query_win_set_status(lm_query_win_t *win, bool status);
void lm_query_win_set_text(lm_query_win_t *win, const char* text);
void lm_query_win_scrol_up(lm_query_win_t *win);
void lm_query_win_scrol_down(lm_query_win_t *win);
void lm_query_win_refresh(lm_query_win_t* win);



#ifdef __cplusplus
} /*extern "C"*/
#endif

#endif //__LM_WIN_H__
